<?php
        require_once('auth.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
<HEAD>
<TITLE>Calculate RDCs</TITLE>
<link href="style.css" rel="stylesheet" type="text/css" />
</HEAD>
<script type="text/javascript">
function newPopup(url) {
        popupWindow = window.open(
        url, 'popUpWindow', 'height=450,width=800,left=50,top=50,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}
function newPopup2(url) {
        popupWindow = window.open(
        url,'popUpWindow','height=450,width=400,left=50,top=50,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}
</script>
<BODY>
<center>
<img src="redcat_logo.jpg">
</center>
<div>
<a href="JavaScript:newPopup('account.php');" style="float:left">My Files</a>
<a href="logout.php" style="float:right">Logout</a>
</div><br />

<div>
<a href="JavaScript:newPopup2('help-menu.php');" style="float:left">Click here for help</a>
</div><br /><br />

<div>
<form method="GET" action="/REDCAT/return-upload.php"><input type="submit" name="return" id="return" value="Return to Data" style="float:right"></form>
</div><br /><br />

<H3 align="left">Enter data parameters:</H3>
<H3 align="center">
<table border="1">
  <form action="/REDCAT/calculated.php" method="POST" enctype="multipart/form-data">
<tr><td>Sxx:  <input type="text" name="sxx" id="sxx"></td>
<td>Syy:  <input type="text" name="syy" id="sxx"></td>
<td>Szz:  <input type="text" name="szz" id="szz"></td></tr>
<tr><td>Alpha:  <input type="text" name="a" id="a"></td>
<td>Beta:  <input type="text" name="b" id="b"></td>
<td>Gamma:  <input type="text" name="c" id="c"></td></tr>
<tr><td></td><td>Error:  <input type="text" name="error" id="error"></td><td></td></tr>
<tr><td></td><td align="center"><input type="submit" name="Calculate" value="Calculate" /></form></td><td></td></tr>
</table>
</H3>

<style type="text/css">
tr.filelisting:hover { background-color:#FFC }
</style>

<?php
//Check for a current session file to display
if(isset($_SESSION['SESS_CURR_FILE']))
{
        $login = $_SESSION['SESS_LOGIN'];
        $currentdir = getcwd();
        $target = $currentdir."/workspace/".$login;
        $file = $_SESSION['SESS_CURR_FILE'];
        //Open the file for reading into a HTML table
        $file = file($file);
        echo '<H5 align = "center">';
        echo '<table border="1">';
        echo '<tr><th align = "center">Eq.#</th><th align = "center">X1</th><th align = "center">Y1</th><th align = "center">Z1</th><th align = "center">X2</th><th align = "center">Y2</th><th align = "center">Z2</th><th align = "center">Dipol</th><th align = "center">Error</th><th align = "center">Comments</th></tr>';
        $eq = 1;
        foreach($file as $line)
        {
                $comment = preg_split('(\/\*)', $line);
                $value = preg_split("/[\s]+/", $comment[0]);
                echo "<tr class = \"filelisting\"><td>$eq</td><td>$value[0]</td><td>$value[1]</td><td>$value[2]</td><td>$value[3]</td><td>$value[4]</td><td>$value[5]</td><td>$value[6]</td><td>$value[8]</td><td>/*$comment[1]</td></tr>";
                $eq++;
        }
        echo '</table>';
        echo '</H3>';
}
session_write_close();
?>

</HTML>
